package com.bawei.wyg.greendaomodel;

import android.database.sqlite.SQLiteDatabase;

import com.bawei.wyg.commonapplication.BaseApplication;
import com.bawei.wyg.greendaomodel.db.DaoMaster;
import com.bawei.wyg.greendaomodel.db.DaoSession;

public class DaoSessionUtils {
    private DaoSessionUtils(){}

    private static DaoSessionUtils daoSessionUtils;

    public static DaoSessionUtils getDaoSessionUtils() {
        if(daoSessionUtils==null){
            daoSessionUtils=new DaoSessionUtils();
        }
        return daoSessionUtils;
    }

    private final static String DBNAME="catch.db";

    private DaoSession daoSession;

    private void init(){
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(BaseApplication.getAppContext(), DBNAME);
        SQLiteDatabase writableDatabase = helper.getWritableDatabase();
        daoSession=new DaoMaster(writableDatabase).newSession();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
